﻿@inject IOptionsMonitor<WebsiteOptions> Options
@inject IStringLocalizer<Video> Localizer

<p><b>@Localizer["H1"]</b></p>

@if (VideoUrl.Any())
{
    foreach (var url in VideoUrl)
    {
        <div class="mb-3">
            <a class="fa-solid fa-video" href="@url" target="_blank"><span class="ms-2">@Localizer["L1"]</span></a>
        </div>
    }
}
else
{
    <div class="mb-3">@Localizer["L2"]</div>
}

@code {
    [NotNull]
    private List<string> VideoUrl { get; } = new List<string>();

    [Parameter]
    public string? Name { get; set; }

    /// <summary>
    ///
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();

        if (!string.IsNullOrEmpty(Name) && Options.CurrentValue.Videos.TryGetValue(Name, out var url))
        {
            VideoUrl.AddRange(url.Split(';').Select(a => $"{Options.CurrentValue.VideoUrl}{a}"));
        }
    }
}
